#include "board.h"
#include "FreeRTOS.h"
#include "task.h"
#include "ad.h"
#include "dht11.h"
#include "stm32f4xx.h"
#include "stdbool.h"

extern void warning_buzzer_init(void);
extern void warning_buzzer_set_onoff(bool bit);

void warning_task(void* param)
{
    warning_buzzer_init();
    while(1)
    {
        uint16_t adc_val = adc_get_value();
        uint16_t mq2_val = mq2_get_value();
        dht_receive_data(WS_DHT);
        if(adc_val > 4000 || mq2_val < 140 || WS_DHT->temperature > 35 || WS_DHT->humidity > 100)
        { 
            warning_buzzer_set_onoff(true);
        }
        else
        {
            warning_buzzer_set_onoff(false);
        }
        vTaskDelay(500);
    }
}
